﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using WWB.SitePointPrivateMessages.Core.Model.Messages;

namespace WWB.SitePointPrivateMessages.Tests.ModelTests
{
    public class PrivateMessageTests
    {
        [Test]
        public void New_message_should_have_same_fingerprint()
        {
            var msg1 = new PrivateMessage();
            var msg2 = new PrivateMessage();
            Assert.That(msg1, Is.Not.SameAs(msg2));
            Assert.That(msg1 == msg2, "Messages should be equal!");
            Assert.That(msg1.FingerPrint == msg2.FingerPrint, "Fingerprints should be equal!");
        }

        [Test]
        public void Messages_with_same_stuff_should_follow_equality_pattern()
        {
            var msg1 = new PrivateMessage()
                           {
                               Title = "Test Message",
                               DateStamp = new DateTime(2010, 1, 1, 13, 13, 13),
                               FromUser = new ForumUser() {Id = 1, Name = "Bob"},
                               ToUsers = new List<ForumUser>() {new ForumUser() {Id = 4, Name = "Crystal"}},
                               Body = "OMG! Come to my party Bob!"
                           };
            var msg2 = new PrivateMessage()
                           {
                               Title = "Test Message",
                               DateStamp = new DateTime(2010, 1, 1, 13, 13, 13),
                               FromUser = new ForumUser() {Id = 1, Name = "Bob"},
                               ToUsers = new List<ForumUser>() {new ForumUser() {Id = 4, Name = "Crystal"}},
                               Body = "OMG! Come to my party Bob!"
                           };
            Assert.That(msg1, Is.Not.SameAs(msg2));
            Assert.That(msg1 == msg2, "Messages should be equal!");
            Assert.That(msg1.FingerPrint == msg2.FingerPrint, "Fingerprints should be equal!");

        }
    }
}
